package fun.lifepoem.blog.utils;

import fun.lifepoem.blog.common.DateEnum;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Yiwyn
 * @create 2022/10/26 20:48
 */
public class DateUtils {

    private DateUtils() {

    }

    private static DateUtils instance;

    public static DateUtils getInstance() {
        if (instance == null) {
            instance = new DateUtils();
        }
        return instance;
    }


    public String getDate(DateEnum dateUnit) {
        String format = "yyyy-MM-dd";
        if (dateUnit != null) {
            format = dateUnit.getFormat();
        }
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        String date = sdf.format(now);
        return date;
    }

}
